The present invention relates to a compiling technique for generating an object code from the source code of a program. More particularly, it relates to a compiling technique for minimizing the memory capacity of a computer required to execute the program through the optimum allocation of memory areas to data used in the program.
As faster computers have been implemented in recent years, it has become possible to execute large calculation problems that had conventionally been difficult to execute. With the trend, there has been increasing demand for computers with larger memory capacities. Although the advancement of semiconductor technology and assembly technology has contributed to increase the memory capacity that can be implemented in a computer, there are limitations to these attempts to physically increase the memory capacity. To go beyond the limitations, there has been proposed and devised a method which uses the function of a programming language and an algorithm for calculation in order to save the memory capacity.
FIG. 13 shows, by way of example, a FORTRAN program the structure of which is typically shown in numerical calculations. In the program shown in FIG. 13, four processes z1 to z4 are repeatedly performed until a specified condition defined in a IF statement is satisfied. In the process z1, the variables A and V are assigned values and referred to, while the variables X and Y are referred to. Similarly in the process z2, the variables B and W are assigned values and referred to, while the variable V is referred to. In the process z3, the variables C and X are assigned values and referred to, while the variable W is referred to. In the process z4, the variables D and Y are assigned values and referred to, while the variable V is referred to. FIG. 14 shows a memory map in the case of executing the program shown in FIG. 13. Since the program uses the eight variables, it occupies areas for 8 words in the memory.
In the program shown in FIG. 13, it is possible to save the memory capacity in use through the following procedure. For example, a COMMON declaration as shown in FIG. 15 can be used, which is an instruction to allocate one memory area in common to any variables each of which is obviously used only in one process, i.e., the variables A, B, C, and D. FIG. 16 is a memory map in the case of executing the FORTRAN program shown in FIG. 15. By using the COMMON declaration, the same memory area is allocated to the four variables A, B, C, and D, thereby saving the memory capacity in use.
Thus, to reduce the memory capacity used by a program, the programmer has conventionally practiced a method of analyzing the data reference relations among individual processes and using a grammar peculiar to a programming language.
However, the conventional method has the following problems.
In the program shown in FIG. 13, the data reference relations among the individual processes are easy to analyze, since it has an extremely simple structure. However, a program used in practice has a more complicated structure so that it is difficult for the programmer to analyze the data reference relations. Therefore, the method in which the programmer specifies the use in common of memory areas by means of a COMMON declaration or the like is extremely inefficient in reducing the memory capacity. Moreover, the method does not necessarily enable the optimum allocation of the memory areas.
Although the method of reducing the memory capacity shown in FIG. 15 is for a single processor, it is more difficult to reduce the memory capacity of a parallel computer provided with a plurality of processors.
The parallel computer executes a program by dividing it into processes which are larger in number than the processors provided therein and performing data transfer between the processors. In this case, a large number of temporary variables are used to perform calculations in the individual processes obtained through the division of the program, data exchange therebetween, and data transfer between the processors. Furthermore, in the case of solving a partial differential equation by a repetitive method, several processes are often repeatedly performed using a value obtained in the preceding process, so that the data reference relations become extremely complicated. Accordingly, it becomes extremely difficult for the programmer to analyze the data reference relations, compared with the case in which a single processor is used. Therefore, the method in which the programmer specifies the use in common of memory areas is extremely inefficient in reducing the memory capacity and it does not necessarily enable the optimum allocation of the memory areas.